int mySqrt(int x)
{
    if(!x) {
        return x;
    }
    double val=x;
    double last;
    do {
        last = val;
        val = (val + x / val) / 2;
    } while(fabs(val - last) > 1e-8);
    return (int)val;
}